/*
 * DateTag.java
 *
 * Created on 2007年7月19日, 下午5:32
 *
 * 花开堪折须直折，莫待无花空折枝！
 *
 */

package com.ecomm.util.taglibs;
import com.ecomm.util.EcomTagLib;
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.TagSupport;
/**
 *
 * <p>Title: 易讯聊天系统</p>
 * <p>Description:
 *  易讯聊天系统
 * </p>
 * <p>Copyright: Copyright (c) 2007</p>
 * <p>Company: 联合易讯 </p>
 * @author <font color='blue'>ppliang</font> &nbsp&nbsp<a href="mailto:pijunliang@hotmail.com">pijunliang@hotmail.com</a>
 * @version 1.0
 * @data  2007年7月19日, 下午5:32
 */
public class DateTag extends TagSupport {
  private String name = null;
  private String nonull = null;
  private String value = null;
  private String format = "%Y-%m-%d %H:%M:%S";
  private String permission = "readonly";
  
    public int doStartTag() throws JspException {
    try {
      HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
      HttpServletResponse response=(HttpServletResponse)pageContext.getResponse();
      
      EcomTagLib stl = (EcomTagLib)request.getAttribute("ecomTaglib");
      if(stl !=null){
        boolean bool = false;
        if(this.getNonull() != null && !this.getNonull().equals("")){
          bool = true;
        }
        String text =  stl.date(this.getName(),bool,this.getValue(),getPermission(),getFormat());
        if(text != null){
          pageContext.getOut().print(text);
          return SKIP_PAGE;
        }
      }
    } catch (IOException ioe) {
      throw new JspTagException("ecomlib tag failed");
    }
    return EVAL_BODY_INCLUDE;
  }
  
  public int doEndTag() {
    return EVAL_PAGE;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getNonull() {
    return nonull;
  }

  public void setNonull(String nonull) {
    this.nonull = nonull;
  }

  public String getValue() {
    return value;
  }

  public void setValue(String value) {
    this.value = value;
  }

  public String getPermission() {
    return permission;
  }

  public void setPermission(String permission) {
    this.permission = permission;
  }

  public String getFormat() {
    return format;
  }

  public void setFormat(String format) {
    this.format = format;
  }
  
}
